package com.csun.cmny.provider.service.impl;

import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.UacGroupLanguageMapper;
import com.csun.cmny.provider.model.domain.UacGroupLanguage;
import com.csun.cmny.provider.service.UacGroupLanguageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2020-01-03 21:17
 * @Description:
 */
@Slf4j
@Service
public class UacGroupLanguageServiceImpl extends BaseService<UacGroupLanguage> implements UacGroupLanguageService {

    @Resource
    private UacGroupLanguageMapper uacGroupLanguageMapper;

    /**
     * 根据机构获取语言
     *
     * @param groupId the group id
     *
     * @return the group language
     */
    @Override
    public String getLanguageByGroupId(Long groupId) {

        return uacGroupLanguageMapper.getLanguageByGroupId(groupId);
    }

    /**
     * 保存机构语言配置
     *
     * @param uacGroupLanguage
     * @return
     */
    @Override
    public Integer saveLanguage(UacGroupLanguage uacGroupLanguage) {

        // 判断是否已经设置
        Integer result = uacGroupLanguageMapper.updateByPrimaryKey(uacGroupLanguage);
        if (result < 1) {
            uacGroupLanguageMapper.insertSelective(uacGroupLanguage);
        }

        return result;
    }
}
